
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Installing a GNU/Linux VM · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-page-footer-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-callouts/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="styles.css">
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="0.2.html" />
    
    
    <link rel="prev" href="PA0.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="PA0.html">
            
                <a href="PA0.html">
            
                    
                    PA0 - 世界诞生的前夜: 开发环境配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.2.1" data-path="0.1.html">
            
                <a href="0.1.html">
            
                    
                    Installing a GNU/Linux VM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="0.2.html">
            
                <a href="0.2.html">
            
                    
                    First Exploration with GNU/Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="0.3.html">
            
                <a href="0.3.html">
            
                    
                    Installing Tools
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="0.4.html">
            
                <a href="0.4.html">
            
                    
                    Configuring vim
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="0.5.html">
            
                <a href="0.5.html">
            
                    
                    More Exploration
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="0.6.html">
            
                <a href="0.6.html">
            
                    
                    Transferring Files between host and container
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="0.7.html">
            
                <a href="0.7.html">
            
                    
                    Acquiring Source Code for PAs
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="PA1.html">
            
                <a href="PA1.html">
            
                    
                    PA1 - 开天辟地的篇章: 最简单的计算机
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="1.1.html">
            
                <a href="1.1.html">
            
                    
                    在开始愉快的PA之旅之前
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="1.2.html">
            
                <a href="1.2.html">
            
                    
                    开天辟地的篇章
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="1.3.html">
            
                <a href="1.3.html">
            
                    
                    RTFSC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="1.4.html">
            
                <a href="1.4.html">
            
                    
                    基础设施
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="1.5.html">
            
                <a href="1.5.html">
            
                    
                    表达式求值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="1.6.html">
            
                <a href="1.6.html">
            
                    
                    监视点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="1.7.html">
            
                <a href="1.7.html">
            
                    
                    i386手册
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="PA2.html">
            
                <a href="PA2.html">
            
                    
                    PA2 - 简单复杂的机器: 冯诺依曼计算机系统
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="2.1.html">
            
                <a href="2.1.html">
            
                    
                    不停计算的机器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="2.2.html">
            
                <a href="2.2.html">
            
                    
                    RTFSC(2)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="2.3.html">
            
                <a href="2.3.html">
            
                    
                    程序, 运行时环境与AM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="2.4.html">
            
                <a href="2.4.html">
            
                    
                    基础设施(2)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="2.5.html">
            
                <a href="2.5.html">
            
                    
                    输入输出
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="PA3.html">
            
                <a href="PA3.html">
            
                    
                    PA3 - 穿越时空的旅程: 批处理系统
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="3.1.html">
            
                <a href="3.1.html">
            
                    
                    最简单的操作系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="3.2.html">
            
                <a href="3.2.html">
            
                    
                    穿越时空的旅程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="3.3.html">
            
                <a href="3.3.html">
            
                    
                    用户程序和系统调用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="3.4.html">
            
                <a href="3.4.html">
            
                    
                    文件系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="3.5.html">
            
                <a href="3.5.html">
            
                    
                    批处理系统
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="PA4.html">
            
                <a href="PA4.html">
            
                    
                    PA4 - 虚实交错的魔法: 分时多任务
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="4.1.html">
            
                <a href="4.1.html">
            
                    
                    多道程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="4.2.html">
            
                <a href="4.2.html">
            
                    
                    虚实交错的魔法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="4.3.html">
            
                <a href="4.3.html">
            
                    
                    超越容量的界限
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="4.4.html">
            
                <a href="4.4.html">
            
                    
                    来自外部的声音
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="4.5.html">
            
                <a href="4.5.html">
            
                    
                    编写不朽的传奇
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="PA5.html">
            
                <a href="PA5.html">
            
                    
                    PA5 - 天下武功唯快不破: 程序与性能
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="5.1.html">
            
                <a href="5.1.html">
            
                    
                    浮点数的支持
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="5.2.html">
            
                <a href="5.2.html">
            
                    
                    通往高速的次元
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="5.3.html">
            
                <a href="5.3.html">
            
                    
                    天下武功唯快不破
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="blank.html">
            
                <a href="blank.html">
            
                    
                    杂项
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="why.html">
            
                <a href="why.html">
            
                    
                    为什么要学习计算机系统基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="submit.html">
            
                <a href="submit.html">
            
                    
                    实验提交要求
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="linux.html">
            
                <a href="linux.html">
            
                    
                    Linux入门教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="man.html">
            
                <a href="man.html">
            
                    
                    man入门教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="git.html">
            
                <a href="git.html">
            
                    
                    git入门教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="i386-intro.html">
            
                <a href="i386-intro.html">
            
                    
                    i386手册指令集阅读指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="exec.html">
            
                <a href="exec.html">
            
                    
                    指令执行例子
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >Installing a GNU/Linux VM</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <p>PA0 is a guide to GNU/Linux development environment configuration.
You are guided to install a GNU/Linux development environment.
All PAs and Labs are done in this environment.
 <font color="red">If you are new to GNU/Linux, and you encounter some troubles during the configuration,
which are not mentioned in this lecture note (such as &quot;No such file or directory&quot;), that is your fault.</font>
Go back to read this lecture note carefully.
 <font color="red">Remember, the machine is always right!</font></p>
<!-- -->
<div class="panel panel-success"><div class="panel-heading"><h3 class="panel-title" id="&#x4FE1;&#x606F;&#x6846;&#x8BF4;&#x660E;"><i class="fa fa-lightbulb-o"></i> &#x4FE1;&#x606F;&#x6846;&#x8BF4;&#x660E;</h3></div><div class="panel-body"><p>&#x8BB2;&#x4E49;&#x4E2D;&#x4F1A;&#x51FA;&#x73B0;&#x4E00;&#x4E9B;&#x4FE1;&#x606F;&#x6846;, &#x6839;&#x636E;&#x5176;&#x989C;&#x8272;&#x548C;&#x5DE6;&#x4E0A;&#x89D2;&#x7684;&#x56FE;&#x6807;&#x53EF;&#x4EE5;&#x5F97;&#x77E5;&#x4FE1;&#x606F;&#x7684;&#x7C7B;&#x522B;.
&#x4F8B;&#x5982;&#x672C;&#x4FE1;&#x606F;&#x6846;&#x5C31;&#x662F;&#x4E00;&#x4E9B;&#x63D0;&#x793A;&#x76F8;&#x5173;&#x7684;&#x5185;&#x5BB9;. &#x5176;&#x5B83;&#x7C7B;&#x522B;&#x4E3B;&#x8981;&#x8FD8;&#x6709;</p><div class="panel panel-success"><div class="panel-heading"><h3 class="panel-title" id="&#x5B9E;&#x9A8C;&#x8FDB;&#x5EA6;&#x76F8;&#x5173;&#x7684;&#x63D0;&#x793A;"><i class="fa fa-flag"></i> &#x5B9E;&#x9A8C;&#x8FDB;&#x5EA6;&#x76F8;&#x5173;&#x7684;&#x63D0;&#x793A;</h3></div><div class="panel-body"></div></div><div class="panel panel-info"><div class="panel-heading"><h3 class="panel-title" id="&#x6269;&#x5C55;&#x9605;&#x8BFB;"><i class="fa fa-comment-o"></i> &#x6269;&#x5C55;&#x9605;&#x8BFB;</h3></div><div class="panel-body"></div></div><div class="panel panel-info"><div class="panel-heading"><h3 class="panel-title" id="&#x9009;&#x505A;&#x601D;&#x8003;&#x9898;"><i class="fa fa-question-circle"></i> &#x9009;&#x505A;&#x601D;&#x8003;&#x9898;</h3></div><div class="panel-body"></div></div><div class="panel panel-warning"><div class="panel-heading"><h3 class="panel-title" id="&#x5B9E;&#x9A8C;&#x5FC5;&#x505A;&#x5185;&#x5BB9;"><i class="fa fa-edit"></i> &#x5B9E;&#x9A8C;&#x5FC5;&#x505A;&#x5185;&#x5BB9;</h3></div><div class="panel-body"></div></div><div class="panel panel-danger"><div class="panel-heading"><h3 class="panel-title" id="&#x5B9E;&#x9A8C;&#x8FDB;&#x5EA6;&#x76F8;&#x5173;&#x7684;&#x5FC5;&#x8BFB;&#x4FE1;&#x606F;"><i class="fa fa-exclamation"></i> &#x5B9E;&#x9A8C;&#x8FDB;&#x5EA6;&#x76F8;&#x5173;&#x7684;&#x5FC5;&#x8BFB;&#x4FE1;&#x606F;</h3></div><div class="panel-body"></div></div><div class="panel panel-danger"><div class="panel-heading"><h3 class="panel-title" id="&#x91CD;&#x8981;&#x6027;&#x8D85;&#x8D8A;&#x5B9E;&#x9A8C;&#x7684;&#x539F;&#x5219;&#x4E0E;&#x65B9;&#x6CD5;"><i class="fa fa-bullhorn"></i> &#x91CD;&#x8981;&#x6027;&#x8D85;&#x8D8A;&#x5B9E;&#x9A8C;&#x7684;&#x539F;&#x5219;&#x4E0E;&#x65B9;&#x6CD5;</h3></div><div class="panel-body"></div></div></div></div>
<!-- -->
<div class="panel panel-danger"><div class="panel-heading"><h3 class="panel-title" id="&#x5BF9;-&#x4F60;&#x6CA1;&#x6709;&#x770B;&#x9519;-&#x9664;&#x4E86;&#x4E00;&#x4E9B;&#x91CD;&#x8981;&#x7684;&#x4FE1;&#x606F;&#x4E4B;&#x5916;-pa0&#x7684;&#x5B9E;&#x9A8C;&#x8BB2;&#x4E49;&#x90FD;&#x662F;&#x82F1;&#x6587;"><i class="fa fa-bullhorn"></i> &#x5BF9;, &#x4F60;&#x6CA1;&#x6709;&#x770B;&#x9519;, &#x9664;&#x4E86;&#x4E00;&#x4E9B;&#x91CD;&#x8981;&#x7684;&#x4FE1;&#x606F;&#x4E4B;&#x5916;, PA0&#x7684;&#x5B9E;&#x9A8C;&#x8BB2;&#x4E49;&#x90FD;&#x662F;&#x82F1;&#x6587;!</h3></div><div class="panel-body"><p>&#x968F;&#x7740;&#x79D1;&#x5B66;&#x6280;&#x672F;&#x7684;&#x53D1;&#x5C55;, &#x5728;&#x56FD;&#x9645;&#x5B66;&#x672F;&#x4EA4;&#x6D41;&#x4E2D;&#x4F7F;&#x7528;&#x82F1;&#x8BED;&#x5DF2;&#x7ECF;&#x6210;&#x4E3A;&#x5E38;&#x6001;:
&#x9876;&#x5C16;&#x7684;&#x8BBA;&#x6587;&#x65E0;&#x4E00;&#x4E0D;&#x4F7F;&#x7528;&#x82F1;&#x6587;&#x6765;&#x4E66;&#x5199;, &#x5728;&#x56FD;&#x9645;&#x4E0A;&#x516C;&#x8BA4;&#x7684;&#x8BA1;&#x7B97;&#x673A;&#x9886;&#x57DF;&#x7ECF;&#x5178;&#x4E66;&#x7C4D;&#x4E5F;&#x662F;&#x4F7F;&#x7528;&#x82F1;&#x6587;&#x7F16;&#x8457;.
&#x9876;&#x5C16;&#x7684;&#x8BBA;&#x6587;&#x6CA1;&#x6709;&#x4E2D;&#x6587;&#x7FFB;&#x8BD1;&#x7248;; &#x5982;&#x679C;&#x9700;&#x8981;&#x83B7;&#x53D6;&#x4FE1;&#x606F;, &#x4E5F;&#x5E94;&#x8BE5;&#x4E3B;&#x52A8;&#x53BB;&#x9605;&#x8BFB;&#x82F1;&#x6587;&#x6750;&#x6599;, &#x800C;&#x4E0D;&#x662F;&#x7B49;&#x7FFB;&#x8BD1;&#x7248;&#x51FA;&#x7248;.
&quot;&#x6211;&#x662F;&#x4E2D;&#x56FD;&#x4EBA;, &#x6211;&#x53EA;&#x770B;&#x4E2D;&#x6587;&quot;&#x8FD9;&#x7C7B;&#x89C2;&#x70B9;&#x5DF2;&#x7ECF;&#x4E0D;&#x7B26;&#x5408;&#x65F6;&#x4EE3;&#x53D1;&#x5C55;&#x7684;&#x6F6E;&#x6D41;,
&#x8981;&#x7AD9;&#x5728;&#x65F6;&#x4EE3;&#x7684;&#x6700;&#x524D;&#x6CBF;, &#x9605;&#x8BFB;&#x82F1;&#x6587;&#x6750;&#x6599;&#x7684;&#x80FD;&#x529B;&#x662F;&#x4E0D;&#x53EF;&#x6216;&#x7F3A;&#x7684;.</p><p>&#x9605;&#x8BFB;&#x82F1;&#x6587;&#x6750;&#x6599;, &#x65E0;&#x975E;&#x5C31;&#x662F;&quot;&#x4E0D;&#x4F1A;&#x7684;&#x5355;&#x8BCD;&#x67E5;&#x5B57;&#x5178;, &#x4E0D;&#x61C2;&#x7684;&#x53E5;&#x5B50;&#x53CD;&#x590D;&#x8BFB;&quot;.
&#x5982;&#x4ECA;&#x7F51;&#x4E0A;&#x6709;&#x5404;&#x79CD;&#x8BCD;&#x9738;&#x53EF;&#x89E3;&#x71C3;&#x7709;&#x4E4B;&#x6025;, &#x4F46;&#x82F1;&#x6587;&#x9605;&#x8BFB;&#x80FD;&#x529B;&#x7684;&#x63D0;&#x9AD8;&#x8D35;&#x5728;&#x575A;&#x6301;.
&quot;&#x521A;&#x5F00;&#x59CB;&#x89C9;&#x5F97;&#x9605;&#x8BFB;&#x82F1;&#x6587;&#x6548;&#x7387;&#x4F4E;&quot;, &#x662F;&#x6240;&#x6709;&#x4E2D;&#x56FD;&#x4EBA;&#x90FD;&#x65E0;&#x6CD5;&#x907F;&#x514D;&#x7684;&#x7ECF;&#x5386;.
&#x5982;&#x679C;&#x4F60;&#x53D1;&#x73B0;&#x8EAB;&#x8FB9;&#x7684;&#x5927;&#x795E;&#x53EF;&#x4EE5;&#x5F88;&#x8F7B;&#x677E;&#x5730;&#x9605;&#x8BFB;&#x82F1;&#x6587;&#x6750;&#x6599;, &#x90A3;&#x662F;&#x56E0;&#x4E3A;&#x4ED6;&#x4EEC;&#x65E9;&#x5C31;&#x514B;&#x670D;&#x4E86;&#x8FD9;&#x4E9B;&#x56F0;&#x96BE;.
&#x5F15;&#x7528;&#x9648;&#x9053;&#x84C4;&#x8001;&#x5E08;&#x7684;&#x8BDD;: &#x575A;&#x6301;&#x4E00;&#x5E74;, &#x4F60;&#x5C31;&#x4F1A;&#x53D1;&#x73B0;&#x6709;&#x4E0D;&#x540C;; &#x575A;&#x6301;&#x4E24;&#x5E74;, &#x4F60;&#x5C31;&#x4F1A;&#x53D1;&#x73B0;&#x5927;&#x6709;&#x4E0D;&#x540C;.</p><p>&#x6487;&#x5F00;&#x8FD9;&#x4E9B;&#x9AD8;&#x5927;&#x4E0A;&#x7684;&#x8BDD;&#x9898;&#x4E0D;&#x8BF4;, &#x9605;&#x8BFB;&#x82F1;&#x6587;&#x6750;&#x6599;&#x548C;&#x4F60;&#x6709;&#x4EC0;&#x4E48;&#x5173;&#x7CFB;&#x5462;?
&#x6709;! &#x56E0;&#x4E3A;&#x5728;PA&#x4E2D;&#x966A;&#x4F34;&#x4F60;&#x7684;, &#x5C31;&#x662F;&#x6CA1;&#x6709;&#x4E2D;&#x6587;&#x7248;&#x7684;<a href="http://microsym.com/editor/assets/386intel.pdf" target="_blank">i386&#x624B;&#x518C;</a>,
&#x5F53;&#x7136;&#x8FD8;&#x6709;<code>man</code>: &#x5982;&#x679C;&#x4F60;&#x4E0D;&#x613F;&#x610F;&#x9605;&#x8BFB;&#x82F1;&#x6587;&#x6750;&#x6599;, &#x4F60;&#x662F;&#x6CE8;&#x5B9A;&#x65E0;&#x6CD5;&#x72EC;&#x7ACB;&#x5B8C;&#x6210;PA&#x7684;.</p><p>&#x4F5C;&#x4E3A;&#x8FC7;&#x6E21;, &#x6211;&#x4EEC;&#x4E3A;&#x5927;&#x5BB6;&#x51C6;&#x5907;&#x4E86;&#x5168;&#x82F1;&#x6587;&#x7684;PA0.
PA0&#x7684;&#x76EE;&#x7684;&#x662F;&#x914D;&#x7F6E;&#x5B9E;&#x9A8C;&#x73AF;&#x5883;, &#x540C;&#x65F6;&#x719F;&#x6089;GNU/Linux&#x4E0B;&#x7684;&#x5DE5;&#x4F5C;&#x65B9;&#x5F0F;.
&#x5176;&#x4E2D;&#x6D89;&#x53CA;&#x7684;&#x90FD;&#x662F;&#x4E00;&#x4E9B;&#x64CD;&#x4F5C;&#x6027;&#x7684;&#x6B65;&#x9AA4;, &#x4F60;&#x4E0D;&#x5FC5;&#x4E3A;&#x4E86;&#x5B8C;&#x6210;PA0&#x800C;&#x601D;&#x8003;&#x6DF1;&#x5965;&#x7684;&#x95EE;&#x9898;.</p><p><font color="red">&#x4F60;&#x9700;&#x8981;&#x72EC;&#x7ACB;&#x5B8C;&#x6210;PA0, &#x8BF7;&#x4F60;&#x8BA4;&#x771F;&#x9605;&#x8BFB;&#x8BB2;&#x4E49;&#x4E2D;&#x7684;&#x6BCF;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;, &#x5E76;&#x6309;&#x7167;&#x8BB2;&#x4E49;&#x4E2D;&#x7684;&#x5185;&#x5BB9;&#x8FDB;&#x884C;&#x64CD;&#x4F5C;:
&#x5F53;&#x8BB2;&#x4E49;&#x63D0;&#x5230;&#x8981;&#x5728;&#x4E92;&#x8054;&#x7F51;&#x4E0A;&#x641C;&#x7D22;&#x67D0;&#x4E2A;&#x5185;&#x5BB9;&#x65F6;, &#x4F60;&#x5C31;&#x53BB;&#x4E92;&#x8054;&#x7F51;&#x4E0A;&#x641C;&#x7D22;&#x8FD9;&#x4E2A;&#x5185;&#x5BB9;.
&#x5982;&#x679C;&#x9047;&#x5230;&#x4E86;&#x9519;&#x8BEF;, &#x8BF7;&#x8BA4;&#x771F;&#x53CD;&#x590D;&#x9605;&#x8BFB;&#x8BB2;&#x4E49;&#x5185;&#x5BB9;, <u>&#x673A;&#x5668;&#x6C38;&#x8FDC;&#x662F;&#x5BF9;&#x7684;</u>.</font>
&#x5982;&#x679C;&#x4F60;&#x662F;&#x7B2C;&#x4E00;&#x6B21;&#x4F7F;&#x7528;GNU/Linux, &#x4F60;&#x8FD8;&#x9700;&#x8981;&#x67E5;&#x9605;&#x5927;&#x91CF;&#x8D44;&#x6599;&#x6216;&#x6559;&#x7A0B;&#x6765;&#x5B66;&#x4E60;&#x4E00;&#x4E9B;&#x65B0;&#x5DE5;&#x5177;&#x7684;&#x4F7F;&#x7528;&#x65B9;&#x6CD5;,
&#x8FD9;&#x9700;&#x8981;&#x82B1;&#x8D39;&#x5927;&#x91CF;&#x7684;&#x65F6;&#x95F4;(&#x4F8B;&#x5982;&#x4F60;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x82B1;&#x8D39;&#x4E00;&#x4E2A;&#x4E0B;&#x5348;&#x7684;&#x65F6;&#x95F4;, &#x4EC5;&#x4EC5;&#x662F;&#x4E3A;&#x4E86;&#x4F7F;&#x7528;<code>vim</code>&#x5728;&#x6587;&#x4EF6;&#x4E2D;&#x952E;&#x5165;&#x4E24;&#x884C;&#x5185;&#x5BB9;).
&#x8FD9;&#x5C31;&#x50CF;&#x9605;&#x8BFB;&#x82F1;&#x6587;&#x6750;&#x6599;&#x4E00;&#x6837;, &#x4E00;&#x5F00;&#x59CB;&#x4F60;&#x4F1A;&#x89C9;&#x5F97;&#x6548;&#x7387;&#x5F88;&#x4F4E;, &#x4F46;&#x968F;&#x7740;&#x65F6;&#x95F4;&#x7684;&#x63A8;&#x79FB;, &#x4F60;&#x5BF9;&#x8FD9;&#x4E9B;&#x5DE5;&#x5177;&#x7684;&#x4F7F;&#x7528;&#x4F1A;&#x8D8A;&#x6765;&#x8D8A;&#x719F;&#x7EC3;.
&#x76F8;&#x53CD;, &#x5982;&#x679C;&#x4F60;&#x901A;&#x8FC7;&quot;&#x6295;&#x673A;&#x53D6;&#x5DE7;&quot;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x5B8C;&#x6210;PA0, &#x4F60;&#x5C06;&#x4F1A;&#x9A6C;&#x4E0A;&#x5728;PA1&#x4E2D;&#x9047;&#x5230;&#x9EBB;&#x70E6;.
&#x6B63;&#x5982;etone&#x6240;&#x8BF4;, &#x4F60;&#x5728;&#x4E13;&#x4E1A;&#x4E0A;&#x7684;&#x6280;&#x4E0D;&#x5982;&#x4EBA;, &#x8FDF;&#x65E9;&#x6709;&#x4E00;&#x5929;&#x4F1A;&#x627E;&#x4E0A;&#x6765;.</p><p>&#x53E6;&#x5916;, PA0&#x7684;&#x8BB2;&#x4E49;&#x53EA;&#x8D1F;&#x8D23;&#x7ED9;&#x51FA;&#x64CD;&#x4F5C;&#x8FC7;&#x7A0B;, &#x5E76;&#x4E0D;&#x8D1F;&#x8D23;&#x89E3;&#x91CA;&#x8FD9;&#x4E9B;&#x64CD;&#x4F5C;&#x76F8;&#x5173;&#x7684;&#x7EC6;&#x8282;&#x548C;&#x539F;&#x7406;.
&#x5982;&#x679C;&#x4F60;&#x5E0C;&#x671B;&#x4E86;&#x89E3;&#x5B83;&#x4EEC;, &#x8BF7;&#x5728;&#x4E92;&#x8054;&#x7F51;&#x4E0A;&#x641C;&#x7D22;&#x76F8;&#x5173;&#x5185;&#x5BB9;.</p></div></div>
<h2 id="installing-docker">Installing Docker</h2>
<p><a href="https://www.docker.com" target="_blank">Docker</a> is an implementation of the lightweight virtualization technology.
Virtual machines built by this technology is called &quot;container&quot;.
By using Docker, it is very easy to deploy GNU/Linux applications.</p>
<p>If you already have one copy of GNU/Linux distribution different from which we recommend,
and you want to use your copy as the development environment,
we still encourage you to install docker on your GNU/Linux distribution
to use the same GNU/Linux distribution we recommend over docker
to avoid issues brought by platform disparity.
Refer to <a href="https://docs.docker.com" target="_blank">Docker online Document</a> for more information about installing Docker for GNU/Linux.
It is OK if you still insist on your GNU/Linux distribution.
But if you encounter some troubles because of platform disparity,
please search the Internet for trouble-shooting.</p>
<p>It is also OK to use traditional virtual machines, such as VMWare or VirtualBox, instead of Docker.
If you decide to do this and you do not have a copy of GNU/Linux,
please install <a href="http://www.debian.org" target="_blank">Debian 9</a> distribution in the virtual machine.
Also, please search the Internet for trouble-shooting if you have any problems about virtual machines.</p>
<div class="panel panel-danger"><div class="panel-heading"><h3 class="panel-title" id="&#x5FC5;&#x987B;&#x4F7F;&#x7528;64&#x4F4D;&#x7684;gnulinux"><i class="fa fa-exclamation"></i> &#x5FC5;&#x987B;&#x4F7F;&#x7528;64&#x4F4D;&#x7684;GNU/Linux</h3></div><div class="panel-body"><p>&#x5982;&#x679C;&#x4F60;&#x6253;&#x7B97;&#x4F7F;&#x7528;&#x5DF2;&#x6709;&#x7684;GNU/Linux&#x5E73;&#x53F0;, &#x8BF7;&#x786E;&#x4FDD;&#x5B83;&#x662F;64&#x4F4D;&#x7248;&#x672C;.
&#x4ECA;&#x5E74;PA&#x7684;&#x65B0;&#x589E;&#x7279;&#x6027;&#x4F1A;&#x4F9D;&#x8D56;&#x4E8E;64&#x4F4D;&#x5E73;&#x53F0;.</p></div></div>
<p>Download Docker from <a href="https://www.docker.com/community-edition#/download" target="_blank">this</a> website according to your host operating system,
then install Docker with default settings.
Reboot the system if necessary.
If your operating system can not meet the requirement of installing Docker,
please upgrade your operating system.
Do not install <code>Docker Toolbox</code> instead.
It seems not very stable in Windows since it is based on VirtualBox.</p>
<h2 id="preparing-dockerfile">Preparing Dockerfile</h2>
<p><code>Dockerfile</code> is the configuration file used to build a Docker image.
Now we are going to prepare a Dockerfile with proper content by using the
<a href="http://en.wikipedia.org/wiki/Text_terminal#Text_terminals" target="_blank">terminal</a> working environment.</p>
<ul>
<li>If your host is GNU/Linux or Mac, you can use the default terminal in the system.</li>
<li>If your host is Windows, open <code>PowerShell</code>.</li>
</ul>
<p>Type the following commands after the prompt, one command per line.
Every command is issued by pressing the <code>Enter</code> key.
The contents after a <code>#</code> is the comment about the command,
and you do not need to type the comment.</p>
<pre><code>mkdir mydocker     # create a directory with name &quot;mydocker&quot;
cd mydocker        # enter this directory
</code></pre><p>Now use the text editor in the host to new a file called <code>Dockerfile</code>.</p>
<ul>
<li>Windows: Type command <code>notepad Dockerfile</code> to open Notepad.</li>
<li>MacOS: Type command <code>open -e Dockerfile</code> to open TextEdit.</li>
<li>GNU/Linux: Use your favourite editor to open Dockerfile.</li>
</ul>
<p>Now copy the following contents into Dockerfile:</p>
<pre><code class="lang-dockerfile"> <span class="hljs-comment"># setting base image</span>
<span class="hljs-keyword">FROM</span> debian

<span class="hljs-keyword">RUN</span> <span class="bash">apt-get update
</span>
 <span class="hljs-comment"># Set the locale</span>
<span class="hljs-keyword">RUN</span> <span class="bash">apt-get install -y locales
</span><span class="hljs-keyword">RUN</span> <span class="bash">sed -i <span class="hljs-_">-e</span> <span class="hljs-string">&apos;s/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/&apos;</span> /etc/locale.gen
</span><span class="hljs-keyword">RUN</span> <span class="bash">dpkg-reconfigure --frontend=noninteractive locales
</span><span class="hljs-keyword">RUN</span> <span class="bash">update-locale LANG=en_US.UTF-8
</span><span class="hljs-keyword">ENV</span> LANG en_US.UTF-<span class="hljs-number">8</span>
<span class="hljs-keyword">ENV</span> LANGUAGE en_US:en
<span class="hljs-keyword">ENV</span> LC_ALL en_US.UTF-<span class="hljs-number">8</span>

 <span class="hljs-comment"># new a directory for sshd to run</span>
<span class="hljs-keyword">RUN</span> <span class="bash">mkdir -p /var/run/sshd
</span> <span class="hljs-comment"># installing ssh server</span>
<span class="hljs-keyword">RUN</span> <span class="bash">apt-get install -y openssh-server
</span>
 <span class="hljs-comment"># installing sudo</span>
<span class="hljs-keyword">RUN</span> <span class="bash">apt-get install -y sudo
</span>
 <span class="hljs-comment"># make ssh services use IPv4 to let X11 forwarding work correctly</span>
<span class="hljs-keyword">RUN</span> <span class="bash"><span class="hljs-built_in">echo</span> AddressFamily inet &gt;&gt; /etc/ssh/sshd_config
</span>
 <span class="hljs-comment"># defining user account imformation</span>
ARG username=ics
ARG userpasswd=ics

 <span class="hljs-comment"># adding user</span>
<span class="hljs-keyword">RUN</span> <span class="bash">useradd -ms /bin/bash <span class="hljs-variable">$username</span> &amp;&amp; (<span class="hljs-built_in">echo</span> <span class="hljs-variable">$username</span>:<span class="hljs-variable">$userpasswd</span> | chpasswd)
</span>
 <span class="hljs-comment"># adding user to sudo group</span>
<span class="hljs-keyword">RUN</span> <span class="bash">adduser <span class="hljs-variable">$username</span> sudo
</span>
 <span class="hljs-comment"># setting running application</span>
<span class="hljs-keyword">CMD</span> <span class="bash">/usr/sbin/sshd -D
</span></code></pre>
<p>We choose the Debian distribution as the base image,
since it can be quite small.
Change <code>username</code> and <code>userpasswd</code> above to your favourite account settings.
Save the file and exit the editor.</p>
<p>For Windows user, <code>notepad</code> will append suffix <code>.txt</code> to the saved file.
This is unexpected.
Use the following command to rename the file.</p>
<pre><code>mv Dockerfile.txt Dockerfile     # rename the file to remove the suffix in Windows
</code></pre><h2 id="building-docker-image">Building Docker image</h2>
<p>Keep the Internet conntected.
Type the following command to build our image:</p>
<pre><code>docker build -t ics-image .
</code></pre><p>This command will build an image with a tag <code>ics-image</code>,
using the Dockerfile in the current directory (mydocker).
In particular, if your host is GNU/Linux,
all Docker commands should be executed with root privilege,
or alternatively you can add your account to the group <code>docker</code> before executing any docker commands.
If it is the first time you run this command,
Docker will pull the base image <code>debian</code> from <a href="https://hub.docker.com/" target="_blank">Docker Hub</a>.
This will cost several minutes to finish.</p>
<p>After the command above finished, type the following command to show Docker images:</p>
<pre><code>docker images
</code></pre><p>This command will show information about all Docker images.</p>
<pre><code>REPOSITORY           TAG          IMAGE ID          CREATED             SIZE
ics-image            latest       7d9495d03763      4 minutes ago       210 MB
debian               latest       fb434121fc77      4 hours ago         100 MB
</code></pre><p>If you see a repository with name <code>ics-image</code>, you are done with building image.</p>
<p>Now we can remove the directory mentioned above.</p>
<pre><code>cd ..           # go back to the parent directory
rm -r mydocker  # remove the `mydocker` directory
</code></pre><h2 id="creating-debian-container">Creating Debian container</h2>
<p>After building the image, now we can create a container.
Type the following command:</p>
<pre><code>docker create --name=ics-vm -p 20022:22 --tmpfs /dev/shm:exec --privileged=true ics-image
</code></pre><p>This command will create a container with the following property:</p>
<ul>
<li>the name of the container is <code>ics-vm</code></li>
<li>the Docker image is <code>ics-image</code>, which we just built</li>
<li>the default SSH port (<code>22</code>) in the container is bound to port <code>20022</code> in the docker host</li>
<li>the container will get extended privileges (for GDB to run)</li>
<li>mount <code>/dev/shm</code> with an executable flag</li>
</ul>
<p>If the above command fails because a container with the same name already exists,
type the following command to remove the existing container:</p>
<pre><code>docker rm ics-vm
</code></pre><p>Then create the container again.</p>
<p>To see whether the container is created successfully,
type the following command to show containers:</p>
<pre><code>docker ps -a
</code></pre><p>This command will show information about all Docker containers.
If you see a container with name <code>ics-vm</code>, you are done with creating container.</p>
<footer class="page-footer-ex"> <span class="page-footer-ex-copyright"> By <a href="https://sashimi-yzh.github.io/" target="_blank">Zihao Yu</a>, &#x91C7;&#x7528;<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/cn/" target="_blank">&#x77E5;&#x8BC6;&#x5171;&#x4EAB; &#x7F72;&#x540D;-&#x975E;&#x5546;&#x4E1A;&#x6027;&#x4F7F;&#x7528;-&#x76F8;&#x540C;&#x65B9;&#x5F0F;&#x5171;&#x4EAB; 3.0 &#x4E2D;&#x56FD;&#x5927;&#x9646; &#x8BB8;&#x53EF;&#x534F;&#x8BAE;</a>&#x53D1;&#x5E03; </span> &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span class="page-footer-ex-footer-update"> &#x6B64;&#x9875;&#x9762;&#x4FEE;&#x8BA2;&#x4E8E;:  2019-05-03 18:16:13 </span> </footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="PA0.html" class="navigation navigation-prev " aria-label="Previous page: PA0 - 世界诞生的前夜: 开发环境配置">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="0.2.html" class="navigation navigation-next " aria-label="Next page: First Exploration with GNU/Linux">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Installing a GNU/Linux VM","level":"1.2.1","depth":2,"next":{"title":"First Exploration with GNU/Linux","level":"1.2.2","depth":2,"path":"0.2.md","ref":"0.2.md","articles":[]},"previous":{"title":"PA0 - 世界诞生的前夜: 开发环境配置","level":"1.2","depth":1,"path":"PA0.md","ref":"PA0.md","articles":[{"title":"Installing a GNU/Linux VM","level":"1.2.1","depth":2,"path":"0.1.md","ref":"0.1.md","articles":[]},{"title":"First Exploration with GNU/Linux","level":"1.2.2","depth":2,"path":"0.2.md","ref":"0.2.md","articles":[]},{"title":"Installing Tools","level":"1.2.3","depth":2,"path":"0.3.md","ref":"0.3.md","articles":[]},{"title":"Configuring vim","level":"1.2.4","depth":2,"path":"0.4.md","ref":"0.4.md","articles":[]},{"title":"More Exploration","level":"1.2.5","depth":2,"path":"0.5.md","ref":"0.5.md","articles":[]},{"title":"Transferring Files between host and container","level":"1.2.6","depth":2,"path":"0.6.md","ref":"0.6.md","articles":[]},{"title":"Acquiring Source Code for PAs","level":"1.2.7","depth":2,"path":"0.7.md","ref":"0.7.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"3.x.x","theme":"default","variables":{},"plugins":["localized-footer","page-footer-ex","callouts"],"pluginsConfig":{"callouts":{"flag":{"alert":"success","picto":"fa-flag"},"question":{"alert":"info","picto":"fa-question-circle"},"info":{"alert":"info","picto":"fa-info-circle"},"todo":{"alert":"warning","picto":"fa-edit"},"caution":{"alert":"danger","picto":"fa-bullhorn"},"danger":{"alert":"danger","picto":"fa-exclamation"},"showTypeInHeader":false},"page-footer-ex":{"copyright":"By [Zihao Yu](https://sashimi-yzh.github.io/), 采用[知识共享 署名-非商业性使用-相同方式共享 3.0 中国大陆 许可协议](http://creativecommons.org/licenses/by-nc-sa/3.0/cn/)发布","markdown":true,"update_format":"YYYY-MM-DD HH:mm:ss","update_label":"此页面修订于: "},"search":{},"localized-footer":{"filename":"FOOTER.md","hline":"true"},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles.css","pdf":"styles.css"}},"file":{"path":"0.1.md","mtime":"2019-05-03T10:16:13.720Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-03T10:26:23.925Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

